//
//  ZSTabBarController.swift
//  ZSWeibo
//
//  Created by zsj1992 on 16/4/6.
//  Copyright © 2016年 ichange. All rights reserved.
//

import UIKit

class ZSTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        let tabBar = ZSTabBar()
        setValue(tabBar, forKey: "tabBar")
        
        tabBar.btnPlus.addTarget(self, action: "btnPlusDidClick", forControlEvents: .TouchUpInside)
        
        tabBar.tintColor = UIColor.orangeColor()
        
        addChildViewController(ZSHomeController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(ZSMessageController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(ZSDiscoveryController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(ZSProfileController(), title: "我的", imageName: "tabbar_profile")
    }

    func btnPlusDidClick(){
    print("点击了发布按钮")
    }
    
    
     func addChildViewController(childController: UIViewController,title : String,imageName : String) {
        
//        childController.tabBarItem.title = title
//        
//        childController.navigationItem.title = title

        childController.title = title
        
        childController.tabBarItem.image = UIImage(named: imageName)
        
        childController.tabBarItem.selectedImage = UIImage(named: imageName+"_selected")
        
        let nav = ZSNavicationController.init(rootViewController: childController)

        addChildViewController(nav)
    }

    
    
}
